﻿namespace EOrm
{
    /// <summary>
    /// 数据表拓展方法
    /// </summary>
    public static class TableBuilderExtensions
    {
        /// <summary>
        /// 设置数据表的数据库名称
        /// </summary>
        /// <param name="table">数据表</param>
        /// <param name="dbName">数据表的数据库名称</param>
        /// <returns>数据表</returns>
        public static ITable SetDbName(this ITable table, string dbName)
        {
            CheckBuilder(table);
            table.DbName = dbName;
            return table;
        }

        //===============================================//
        /// <summary>
        /// 验证数据表
        /// </summary>
        /// <param name="table">数据表构建器</param>
        /// <exception cref="ArgumentNullException">变量为空异常</exception>
        private static void CheckBuilder(ITable table)
        {
            if (table == null)
            {
                throw new ArgumentNullException("table", "数据表为空");
            }
        }
    }
}
